﻿#ifndef FACERECVPIC_H
#define FACERECVPIC_H

#include <QObject>
#include <QTcpServer>
#include <QTcpSocket>
#include <QNetworkReply>
#include <QList>
#include <QPair>
#include "oeasycommon.h"
#include "recognize.h"

class FaceRecvCli : public QObject
{
    Q_OBJECT
public:
    explicit FaceRecvCli(QTcpSocket *sock, QString id, STRUCT_RECOG_INFO filter, QObject *parent = 0);
    ~FaceRecvCli();

private:
    QTcpSocket *m_sock;
    QByteArray m_jpg;
    Recognize m_recog;
    clock_t m_recogTime;

signals:
    void error();
    void textRecv(QString);

public slots:
    void onError(QAbstractSocket::SocketError);
    void onRead();
    void onPostOver(const QByteArray &, const QByteArray &);
};

class FaceRecvPic : public QObject
{
    Q_OBJECT
public:
    explicit FaceRecvPic(int recvPort, QString id, STRUCT_RECOG_INFO filter, QObject *parent = 0);
    ~FaceRecvPic();

private:
    QString m_id;
    STRUCT_RECOG_INFO m_filter;
    QTcpServer m_jpgServer;
    QList<FaceRecvCli*> m_cliList;

signals:
    void textRecv(QString);

public slots:
    void onNewConnection();
    void onCloseConnect();
};

#endif // FACERECVPIC_H
